// 导入配置好的 axios
import http from '@/utils/request'

// 获取vip商品类型
/**
 *
 * @returns {Promise} 返回一个Promise
 */
export const getVipProduct = () =>
  http.get('/product/get_product', {
    params: { category_id: '20210827165510715' } // 类目id
  })

// 下单
/**
 *
 * @param {String} product_id 商品id
 * @param {String} quantity 商品数量
 * @returns {Promise} 返回一个Promise
 */
export const createPreorder = (product_id, quantity) =>
  http.post('/order/pre_order', { product_id, quantity })

// 发起支付
/**
 *
 * @param {String} order_id 订单的id
 * @returns {Promise} 返回一个Promise
 */
export const startPay = order_id => http.post('/pay/payment', { order_id })

// 查询支付结果
/**
 *
 * @param {String} order_id 订单id
 * @returns {Promise} 返回一个Promise
 */
export const queryOrderStatus = order_id =>
  http.get('/order/query_order_status', { params: { order_id } })

// 获取订单详情/订单
/**
 *
 * @param {String} order_id 订单id 不穿获取所有订单
 * @returns {Promise} 返回一个Promise
 */
export const getOrder = (order_id = '') =>
  http.post('/order/get_order', { order_id })

// 删除指定订单
/**
 *
 * @param {String} order_id 订单id
 * @returns {Promise} 返回一个Promise
 */
export const delOrder = order_id =>
  http.get('/order/del_order', { params: { order_id } })

// 取消订单
export const cancleOrder = order_id => http.get('/order/cancle', { params: { order_id } }) 
